package com.jzg.jcptadmin.adpter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.app.AppContext;
import com.jzg.jcptadmin.data.local.LocalData;
import com.jzg.jcptadmin.data.vo.CarDetails;
import com.jzg.template.refreshrecycleview.RecycleViewBaseAdapter;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by jzg on 2016/2/23.
 */
public class EvaluationAdapter extends RecycleViewBaseAdapter {
    private List<CarDetails.CarPicListEntity> imageList;
    private AppContext context;


    public EvaluationAdapter(AppContext context,List<CarDetails.CarPicListEntity> imageList) {
        this.context = context;
        this.imageList = imageList;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.item_pic, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        MyViewHolder myViewHolder = (MyViewHolder) holder;
        ImageLoader.getInstance().displayImage(imageList.get(position).getPath(), myViewHolder.pic,context.options);
        myViewHolder.name.setText(LocalData.namesandfujia[position]);
    }

    @Override
    public int getItemCount() {
        return imageList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        ImageView pic;
        TextView name;
        public MyViewHolder(View view) {
            super(view);
            pic = (ImageView) view.findViewById(R.id.pic_item);
            name = (TextView) view.findViewById(R.id.name_text);
        }


    }

}
